package com.glory.erp.auth.resources.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.glory.erp.auth.resources.dao.ResourcesDao;
import com.glory.erp.auth.resources.bean.Resources;
import com.glory.erp.auth.resources.bean.ResourcesQuery;
import com.glory.erp.auth.base.BaseDaoImpl;
import com.glory.erp.auth.base.BaseQueryModel;
import com.glory.erp.auth.dept.bean.DeptQuery;

public class ResourcesDaoImpl extends BaseDaoImpl<Resources> implements ResourcesDao{

	public void doQbc(DetachedCriteria dc,BaseQueryModel qm){
		ResourcesQuery resourcesQuery = (ResourcesQuery)qm;
		if (resourcesQuery.getName() != null
				&& resourcesQuery.getName().trim().length() > 0) {
			dc.add(Restrictions.like("name", "%" + resourcesQuery.getName().trim()
					+ "%"));
		}
	}

	public List<Resources> findAllByEmpUuid(Long uuid) {
		String hql = "select res from Emp em join em.roles ro join ro.resources res where em.uuid = ?";
		return this.getHibernateTemplate().find(hql, uuid);
	}
}